package ModelLayer;
import java.util.ArrayList;

public class LendingContainer
{
    private ArrayList<Lending> lendingList;    
    private static LendingContainer _instance;
    
    public LendingContainer()
    {
        lendingList = new ArrayList<Lending>();
    }
    
        public static LendingContainer getInstance()
    {
        if(_instance == null)
        {
            _instance = new LendingContainer();
        }
        return _instance;
    }
    
    public void addLending(Lending _lending)
    {
        lendingList.add(_lending);
    }
    
    public void removeLending(long _id)
    {
        Lending lending = getLending(_id);
        
        lendingList.remove(lending);
    }
    
    public Lending getLending(long _id)
    {
        Lending n = null;
        
        for(Lending l : lendingList)
        {
            if(l.getID() == _id)
            {
                n = l;
            }
        }
        
        return n;
    }
    
    public ArrayList<Lending> listAllLendings()
    {
        return lendingList;
    }
}
